<!DOCTYPE html>
<html lang="zh">
    <head>
    <!--
        © Material Theme
        https://github.com/viosey/hexo-theme-material
        Version: 1.3.4 -->

    <!-- Title -->
    
    <title>
        
            使用oschina的pages功能让百度收录github博客 | 
        
        Terry Ding&#39;s Blog
    </title>

    <!-- Meta & Info -->
    <meta charset="utf-8">

    <!-- dns prefetch -->
    <meta http-equiv="x-dns-prefetch-control" content="on">
    
    
        <link rel="dns-prefetch" href="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"/>
    
    
    
    
        <link rel="dns-prefetch" href="https://www.google-analytics.com"/>
    
    

    <meta http-equiv="X-UA-Compatible">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="theme-color" content="#0097A7">
    <meta name="author" content="Terry Ding">
    <meta name="description" content="null">
    <meta name="keywords" content="null,seo,baidu,oschina,dns,travis-ci">

    <!-- Favicons -->
    <link rel="icon shortcut" type="image/ico" href="/img/favicon.png">
    <link rel="icon" sizes="192x192" href="/img/favicon.png">
    <link rel="apple-touch-icon" href="/img/favicon.png">

    <!--iOS -->
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-title" content="Title">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="HandheldFriendly" content="True">
    <meta name="MobileOptimized" content="480">

    <!-- Add to homescreen for Chrome on Android -->
    <meta name="mobile-web-app-capable" content="yes">

    <!-- Add to homescreen for Safari on iOS -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-title" content="Terry Ding&#39;s Blog">

    <!-- The Open Graph protocol -->
    <meta property="og:url" content="http://blog.dingtianyu.xyz">
    <meta property="og:type" content="blog">
    <meta property="og:title" content="使用oschina的pages功能让百度收录github博客 | Terry Ding&#39;s Blog">
    <meta property="og:description" content="null">
    <meta property="og:article:tag" content="seo"> <meta property="og:article:tag" content="baidu"> <meta property="og:article:tag" content="oschina"> <meta property="og:article:tag" content="dns"> <meta property="og:article:tag" content="travis-ci"> 

    <!--[if lte IE 9]>
        <link rel="stylesheet" href="/css/ie-blocker.css">

        
            <script src="/js/ie-blocker.zhCN.js"></script>
        
    <![endif]-->

    <!-- Import CSS & jQuery -->
    
        <link rel="stylesheet" href="/css/material.min.css">
        <link rel="stylesheet" href="/css/style.min.css">
        <!-- Config CSS -->


<!-- Other Styles -->
<style>
  body, html {
    font-family: Roboto, "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
  }

  a {
    color: #00838F;
  }

  .mdl-card__media,
  #search-label,
  #search-form-label:after,
  #scheme-Paradox .hot_tags-count,
  #scheme-Paradox .sidebar_archives-count,
  #scheme-Paradox .sidebar-colored .sidebar-header,
  #scheme-Paradox .sidebar-colored .sidebar-badge{
    background-color: #0097A7 !important;
  }

  /* Sidebar User Drop Down Menu Text Color */
  #scheme-Paradox .sidebar-colored .sidebar-nav>.dropdown>.dropdown-menu>li>a:hover,
  #scheme-Paradox .sidebar-colored .sidebar-nav>.dropdown>.dropdown-menu>li>a:focus {
    color: #0097A7 !important;
  }

  #post_entry-right-info,
  .sidebar-colored .sidebar-nav li:hover > a,
  .sidebar-colored .sidebar-nav li:hover > a i,
  .sidebar-colored .sidebar-nav li > a:hover,
  .sidebar-colored .sidebar-nav li > a:hover i,
  .sidebar-colored .sidebar-nav li > a:focus i,
  .sidebar-colored .sidebar-nav > .open > a,
  .sidebar-colored .sidebar-nav > .open > a:hover,
  .sidebar-colored .sidebar-nav > .open > a:focus,
  #ds-reset #ds-ctx .ds-ctx-entry .ds-ctx-head a {
    color: #0097A7 !important;
  }

  .toTop {
    background: #757575 !important;
  }

  .material-layout .material-post>.material-nav,
  .material-layout .material-index>.material-nav,
  .material-nav a {
    color: #757575;
  }

  #scheme-Paradox .MD-burger-layer {
    background-color: #757575;
  }

  #scheme-Paradox #post-toc-trigger-btn {
    color: #757575;
  }

  .post-toc a:hover {
    color: #00838F;
    text-decoration: underline;
  }

</style>


<!-- Theme Background Related-->

    <style>
      body{
        background-color: #F5F5F5;
      }

      /* blog_info bottom background */
      #scheme-Paradox .material-layout .something-else .mdl-card__supporting-text{
        background-color: #fff;
      }
    </style>




<!-- Fade Effect -->

    <style>
      .fade {
        transition: all 800ms linear;
        -webkit-transform: translate3d(0,0,0);
        -moz-transform: translate3d(0,0,0);
        -ms-transform: translate3d(0,0,0);
        -o-transform: translate3d(0,0,0);
        transform: translate3d(0,0,0);
        opacity: 1;
      }

      .fade.out{
        opacity: 0;
      }
    </style>


        <script src="/js/jquery.min.js"></script>
        <script src="/js/queue.js"></script>
    

    <!-- UC Browser Compatible -->
    <script>
        var agent = navigator.userAgent.toLowerCase();
        if(agent.indexOf('ucbrowser')>0) {
            document.write("<link rel=\"stylesheet\" href=\"/css/uc.css\">");
            alert('由于 UC 浏览器使用极旧的内核，而本网站使用了一些新的特性。\n为了您能更好的浏览，推荐使用 Chrome 或 Firefox 浏览器。');
        }
    </script>

    

    
    <!-- Google Analytics -->
    <script>
        (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
        m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
        })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
        ga('create', 'UA-93912232-1', 'auto');ga('send', 'pageview');
    </script>
    


    <!-- Bing Background -->
    

    <!-- Custom Head -->
    
</head>


    
        <body id="scheme-Paradox" class="lazy">
            <div class="material-layout  mdl-js-layout has-drawer is-upgraded">
                

                <!-- Main Container -->
                <main class="material-layout__content" id="main">

                    <!-- Top Anchor -->
                    <div id="top"></div>

                    
                        <!-- Hamburger Button -->
                        <button class="MD-burger-icon sidebar-toggle">
                            <span class="MD-burger-layer"></span>
                        </button>
                    

                    <!-- Post TOC -->

    
    <!-- Back Button -->
    <!--
    <div class="material-back" id="backhome-div" tabindex="0">
        <a class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon"
           href="#" onclick="window.history.back();return false;"
           target="_self"
           role="button"
           data-upgraded=",MaterialButton,MaterialRipple">
            <i class="material-icons" role="presentation">arrow_back</i>
            <span class="mdl-button__ripple-container">
                <span class="mdl-ripple"></span>
            </span>
        </a>
    </div>
    -->

    <!-- Left aligned menu below button -->
    <button id="post-toc-trigger-btn"
        class="mdl-button mdl-js-button mdl-button--icon">
        <i class="material-icons">format_list_numbered</i>
    </button>

    <ul class="post-toc-wrap mdl-menu mdl-menu--bottom-left mdl-js-menu mdl-js-ripple-effect" for="post-toc-trigger-btn" style="max-height:80vh; overflow-y:scroll;">
        <ol class="post-toc"><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#码云pages配置"><span class="post-toc-number">1.</span> <span class="post-toc-text">码云pages配置</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#首先申请码云的账户-略"><span class="post-toc-number">1.1.</span> <span class="post-toc-text">首先申请码云的账户(略)</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#在账户中创建新的项目-根据码云官方文档，个人主页需要是同名项目，项目主页则见文档"><span class="post-toc-number">1.2.</span> <span class="post-toc-text">在账户中创建新的项目(根据码云官方文档，个人主页需要是同名项目，项目主页则见文档)</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#往项目中新建一个index-html文件-git或直接在网页操作均可"><span class="post-toc-number">1.3.</span> <span class="post-toc-text">往项目中新建一个index.html文件(git或直接在网页操作均可)</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#在创建好的项目里点击-服务-pages"><span class="post-toc-number">1.4.</span> <span class="post-toc-text">在创建好的项目里点击 服务-pages</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#默认master分支作为pages的目录，点击启动服务即可"><span class="post-toc-number">1.5.</span> <span class="post-toc-text">默认master分支作为pages的目录，点击启动服务即可</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#最后访问http-yourname-oschina-io"><span class="post-toc-number">1.6.</span> <span class="post-toc-text">最后访问http://yourname.oschina.io</span></a></li></ol></li><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#给百度爬虫专用dns"><span class="post-toc-number">2.</span> <span class="post-toc-text">给百度爬虫专用dns</span></a></li><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#自动化码云的部署"><span class="post-toc-number">3.</span> <span class="post-toc-text">自动化码云的部署</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#配置码云的ssh-key"><span class="post-toc-number">3.1.</span> <span class="post-toc-text">配置码云的ssh key</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#生成加密私钥文件"><span class="post-toc-number">3.2.</span> <span class="post-toc-text">生成加密私钥文件</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#添加travis-ci环境变量"><span class="post-toc-number">3.3.</span> <span class="post-toc-text">添加travis-ci环境变量</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#修改travis-ci配置文件"><span class="post-toc-number">3.4.</span> <span class="post-toc-text">修改travis-ci配置文件</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#部署时间变化"><span class="post-toc-number">3.5.</span> <span class="post-toc-text">部署时间变化</span></a></li></ol></li></ol>

        <!--
        <li class="mdl-menu__item">
            Some Action
        </li>
        -->
    </ul>




<!-- Layouts -->

    <!-- Post Module -->
    <div class="material-post_container">

        <div class="material-post mdl-grid">
            <div class="mdl-card mdl-shadow--4dp mdl-cell mdl-cell--12-col">

                <!-- Post Header(Thumbnail & Title) -->
                
    <!-- Paradox Post Header -->
    
        
            <!-- Random Thumbnail -->
            <div class="post_thumbnail-random mdl-card__media mdl-color-text--grey-50">
            <script>
    var randomNum = Math.floor(Math.random() * 19 + 1);

    $('.post_thumbnail-random').attr('data-original', '/img/random/material-' + randomNum + '.png');
    $('.post_thumbnail-random').addClass('lazy');
</script>

        
    
            <p class="article-headline-p">
                使用oschina的pages功能让百度收录github博客
            </p>
        </div>





                
                    <!-- Paradox Post Info -->
                    <div class="mdl-color-text--grey-700 mdl-card__supporting-text meta">

    <!-- Author Avatar -->
    <div id="author-avatar">
        <img src="/img/avatar.png" width="44px" height="44px" alt="Author Avatar"/>
    </div>
    <!-- Author Name & Date -->
    <div>
        <strong>Terry Ding</strong>
        <span>4月 18, 2017</span>
    </div>

    <div class="section-spacer"></div>

    <!-- Favorite -->
    <!--
        <button id="article-functions-like-button" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon btn-like">
            <i class="material-icons" role="presentation">favorite</i>
            <span class="visuallyhidden">favorites</span>
        </button>
    -->

    <!-- Qrcode -->
    
        <button id="article-functions-qrcode-button" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon">
            <i class="material-icons" role="presentation">devices other</i>
            <span class="visuallyhidden">devices other</span>
        </button>
        <ul class="mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect" for="article-functions-qrcode-button">
            <li class="mdl-menu__item">在其它设备中阅读本文章</li>
            <img src="">
        </ul>
    

    <!-- Tags (bookmark) -->
    
    <button id="article-functions-viewtags-button" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon">
        <i class="material-icons" role="presentation">bookmark</i>
        <span class="visuallyhidden">bookmark</span>
    </button>
    <ul class="mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect" for="article-functions-viewtags-button">
        <li class="mdl-menu__item">
        <a class="post_tag-link" href="/tags/baidu/">baidu</a></li><li class="mdl-menu__item"><a class="post_tag-link" href="/tags/dns/">dns</a></li><li class="mdl-menu__item"><a class="post_tag-link" href="/tags/oschina/">oschina</a></li><li class="mdl-menu__item"><a class="post_tag-link" href="/tags/seo/">seo</a></li><li class="mdl-menu__item"><a class="post_tag-link" href="/tags/travis-ci/">travis-ci</a>
    </ul>
    

    <!-- Share -->
    <button id="article-fuctions-share-button" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon">
    <i class="material-icons" role="presentation">share</i>
    <span class="visuallyhidden">share</span>
</button>
<ul class="mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect" for="article-fuctions-share-button">
    
    <!-- Leancloud Views -->
        <a class="post_share-link" href="#">
            <li class="mdl-menu__item">
                <span id="/2017/04/18/SeoForBaidu/" class="leancloud-views_num" data-flag-title="使用oschina的pages功能让百度收录github博客">
     &nbsp;浏览量
</span>

            </li>
        </a>
    

    

    <!-- Share Weibo -->
    
        <a class="post_share-link" href="http://service.weibo.com/share/share.php?appkey=&title=使用oschina的pages功能让百度收录github博客&url=http://blog.dingtianyu.xyz//2017/04/18/SeoForBaidu/index.html&pic=&searchPic=false&style=simple" target="_blank">
            <li class="mdl-menu__item">
                分享到微博
            </li>
        </a>
    

    <!-- Share Twitter -->
    
        <a class="post_share-link" href="https://twitter.com/intent/tweet?text=使用oschina的pages功能让百度收录github博客&url=http://blog.dingtianyu.xyz//2017/04/18/SeoForBaidu/index.html&via=Terry Ding" target="_blank">
            <li class="mdl-menu__item">
                分享到 Twitter
            </li>
        </a>
    

    <!-- Share Facebook -->
    
        <a class="post_share-link" href="https://www.facebook.com/sharer/sharer.php?u=http://blog.dingtianyu.xyz//2017/04/18/SeoForBaidu/index.html" target="_blank">
            <li class="mdl-menu__item">
                分享到 Facebook
            </li>
        </a>
    

    <!-- Share Google+ -->
    
        <a class="post_share-link" href="https://plus.google.com/share?url=http://blog.dingtianyu.xyz//2017/04/18/SeoForBaidu/index.html" target="_blank">
            <li class="mdl-menu__item">
                分享到 Google+
            </li>
        </a>
    

    <!-- Share LinkedIn -->
    

    <!-- Share QQ -->
    

    <!-- Share Telegram -->
    
</ul>

</div>

                

                <!-- Post Content -->
                <div id="post-content" class="mdl-color-text--grey-700 mdl-card__supporting-text fade out">
    
        <p>今天给博客添加了baidu和google的校验文件，希望能让搜索引擎快速的收录博客的变更，但是操作中发现baidu的爬虫没办法爬去博客的sitemap</p>
<p><img src="baidu-fetch-site-error.png" alt="baidu-fetch-site-error"></p>
<p>于是搜了下这个问题，发现有人向github提出了这个问题，github的回答是将百度的爬虫给屏蔽了。。。</p>
<p>那对于这样的问题我就很无奈了，有人说用cdn，有人说用对百度爬虫另开一台服务器，专门给它爬。(前提是你的博客是绑定了自己域名的)</p>
<p>我就想能不能综合下这两个想法呢?</p>
<p>本身github的博客部署的是静态文件，那静态文件部署在另一个地方应当也可以，就像大家说的给百度爬虫另开一台服务器，但我并不想自己搭建服务器给博客，感觉还是有点负担。看到人家说不要用github，转用gitcafe，我想那我能不能部署两个pages呢，我习惯用github，同时也部署在另一个百度爬虫可以访问的pages服务，这样我一旦部署完成，整个网站都不用我管理什么了。</p>
<p>我以前用过oschina的码云，搜了下，现在码云也支持pages了，那我就可以将我的博客同步到码云上，然后把百度线路的dns转到码云的pages服务对应的地址。</p>
<h1 id="码云pages配置"><a href="#码云pages配置" class="headerlink" title="码云pages配置"></a>码云pages配置</h1><h2 id="首先申请码云的账户-略"><a href="#首先申请码云的账户-略" class="headerlink" title="首先申请码云的账户(略)"></a>首先申请码云的账户(略)</h2><h2 id="在账户中创建新的项目-根据码云官方文档，个人主页需要是同名项目，项目主页则见文档"><a href="#在账户中创建新的项目-根据码云官方文档，个人主页需要是同名项目，项目主页则见文档" class="headerlink" title="在账户中创建新的项目(根据码云官方文档，个人主页需要是同名项目，项目主页则见文档)"></a>在账户中创建新的项目(根据码云<a href="http://git.mydoc.io/?t=154714" target="_blank" rel="external">官方文档</a>，个人主页需要是同名项目，项目主页则见文档)</h2><p><img src="oschina-new-project.png" alt="oschina-new-project"></p>
<h2 id="往项目中新建一个index-html文件-git或直接在网页操作均可"><a href="#往项目中新建一个index-html文件-git或直接在网页操作均可" class="headerlink" title="往项目中新建一个index.html文件(git或直接在网页操作均可)"></a>往项目中新建一个index.html文件(git或直接在网页操作均可)</h2><p><img src="oschina-new-file.png" alt="oschina-new-file"><br><img src="oschina-new-index-file.png" alt="oschina-new-index-file"></p>
<h2 id="在创建好的项目里点击-服务-pages"><a href="#在创建好的项目里点击-服务-pages" class="headerlink" title="在创建好的项目里点击 服务-pages"></a>在创建好的项目里点击 服务-pages</h2><p><img src="oschina-setting-pages.png" alt="oschina-setting-pages"></p>
<h2 id="默认master分支作为pages的目录，点击启动服务即可"><a href="#默认master分支作为pages的目录，点击启动服务即可" class="headerlink" title="默认master分支作为pages的目录，点击启动服务即可"></a>默认master分支作为pages的目录，点击启动服务即可</h2><p><img src="oschina-start-pages.png" alt="oschina-start-pages"></p>
<h2 id="最后访问http-yourname-oschina-io"><a href="#最后访问http-yourname-oschina-io" class="headerlink" title="最后访问http://yourname.oschina.io"></a>最后访问<a href="http://terryding77.oschina.io/" target="_blank" rel="external">http://yourname.oschina.io</a></h2><p><img src="visit-oschina-pages.png" alt="visit-oschina-pages"></p>
<p>这时码云的pages服务就配置完成了，以后在博客变动后向对github提交一样，使用git向码云提交你的修改就行</p>
<h1 id="给百度爬虫专用dns"><a href="#给百度爬虫专用dns" class="headerlink" title="给百度爬虫专用dns"></a>给百度爬虫专用dns</h1><p>我的域名是使用阿里云的域名解析，在这里我需要在原本github.io的解析之外添加一条百度专线的cname<br><img src="aliyun-dns-for-baidu.png" alt="aliyun-dns-for-baidu"><br>如果你觉得oschina的解析在国内更方便，你可以将oschina的解析线路改为默认，github的解析线路改成海外。</p>
<h1 id="自动化码云的部署"><a href="#自动化码云的部署" class="headerlink" title="自动化码云的部署"></a>自动化码云的部署</h1><p>虽然上面的方法解决了百度爬虫爬取的问题，但是我还是觉得比较麻烦，每次都要单独向码云推送下更新，我能不能将这一操作自动化呢?</p>
<p>我在之前就使用travis-ci来自动化部署我github上提交的hexo代码，自动生成站点静态文件并提交到github的master分支上。<br>自动化部署github pages博客请参见</p>
<ol>
<li><a href="http://notes.iissnan.com/2016/publishing-github-pages-with-travis-ci/" target="_blank" rel="external">使用 Travis CI 自动更新 GitHub Pages</a></li>
<li><a href="http://xwartz.xyz/pupa/2016/06/auto-update-with-travis-ci/" target="_blank" rel="external">使用 Travis CI 自动更新 Hexo Blog</a></li>
</ol>
<p>现在我希望的是在travis-ci里添加向码云自动部署的代码。</p>
<h2 id="配置码云的ssh-key"><a href="#配置码云的ssh-key" class="headerlink" title="配置码云的ssh key"></a>配置码云的ssh key</h2><p>我之前自动部署github时可以使用private access token来免密向github提交代码，但是码云并不支持这一特点，所以选择了使用ssh key来完成身份识别。<br>具体操作可参见<a href="http://git.mydoc.io/?t=154712" target="_blank" rel="external">生成并部署SSH key</a><br>操作后会产生~/.ssh/id_rsa和~/.ssh/id_rsa.pub两个文件，其中~/.ssh/id_rsa.pub是给码云的公钥，而~/.ssh/id_rsa私钥文件很重要，需要妥善保管，所以在保证其安全的前提下放入travis-ci中进行自动部署就是我们接下来需要进行处理的地方。</p>
<h2 id="生成加密私钥文件"><a href="#生成加密私钥文件" class="headerlink" title="生成加密私钥文件"></a>生成加密私钥文件</h2><p>上述私钥我们需要在ci部署时使用，但为了安全我们并不能明文存储，同时我尝试放入travis的环境变量也被拒绝。因此，参照travis-ci的<a href="https://docs.travis-ci.com/user/encrypting-files/" target="_blank" rel="external">使用加密文件</a>，我将上一部中产生的私钥进行了加密<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">cd your-git-repo-floder</div><div class="line">cp ~/.ssh/id_rsa .encrypted_secret_key # if you specific name, change id_rsa to that</div><div class="line">echo &quot;.encrypted_secret_key&quot; &gt;&gt; .gitignore</div><div class="line">gpg -c .encrypted_secret_key</div><div class="line"># you need enter a passphrase twice </div><div class="line">git add .encrypted_secret_key.gpg</div></pre></td></tr></table></figure></p>
<p>这时我们添加了一个新的文件进入git仓库.encrypted_secret_key.gpg，同时请记住在执行<code>gpg -c .encrypted_secret_key</code>时输入的passphrase，这是我们接下来需要往travis-ci中设置的环境变量</p>
<h2 id="添加travis-ci环境变量"><a href="#添加travis-ci环境变量" class="headerlink" title="添加travis-ci环境变量"></a>添加travis-ci环境变量</h2><p>将上一步中的passphrase作为super_secret_password环境变量设置到travis-ci中</p>
<p><img src="travis-ci-add-key.png" alt="travis-ci-add-key"></p>
<h2 id="修改travis-ci配置文件"><a href="#修改travis-ci配置文件" class="headerlink" title="修改travis-ci配置文件"></a>修改travis-ci配置文件</h2><p>最后修改travis-ci的配置文件，加入对码云的push操作<br>其中 before_install部分是用于将之前加密过的私钥文件解密并赋予600权限，而在after_script部分增加了最后3行用于向码云免密pull更新后的博客。<br><figure class="highlight yml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div></pre></td><td class="code"><pre><div class="line"><span class="attr">language:</span> <span class="string">node_js</span></div><div class="line"><span class="attr">node_js:</span> <span class="string">lts/*</span></div><div class="line"></div><div class="line"><span class="comment"># S: Build Lifecycle</span></div><div class="line"><span class="attr">install:</span></div><div class="line"><span class="bullet">  -</span> <span class="string">npm</span> <span class="string">install</span></div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">#before_script:</span></div><div class="line"> <span class="comment"># - npm install -g gulp</span></div><div class="line"><span class="attr">before_install:</span></div><div class="line"><span class="bullet">  -</span> <span class="string">echo</span> <span class="string">$super_secret_password</span> <span class="string">| gpg --passphrase-fd 0 $OSC_PRIVATE_KEY_FILE.gpg</span></div><div class="line">  - chmod 600 $OSC_PRIVATE_KEY_FILE</div><div class="line"></div><div class="line"><span class="attr">script:</span></div><div class="line"><span class="bullet">  -</span> <span class="string">cp</span> <span class="string">material_theme_config.yml</span>  <span class="string">themes/hexo-theme-material/_config.yml</span></div><div class="line"><span class="bullet">  -</span> <span class="string">hexo</span> <span class="string">g</span></div><div class="line"></div><div class="line"><span class="attr">after_script:</span></div><div class="line"><span class="bullet">  -</span> <span class="string">cd</span> <span class="string">./public</span></div><div class="line"><span class="bullet">  -</span> <span class="string">git</span> <span class="string">init</span></div><div class="line"><span class="bullet">  -</span> <span class="string">git</span> <span class="string">config</span> <span class="string">user.name</span> <span class="string">"terryding77"</span></div><div class="line"><span class="bullet">  -</span> <span class="string">git</span> <span class="string">config</span> <span class="string">user.email</span> <span class="string">"terryding77@gmail.com"</span></div><div class="line"><span class="bullet">  -</span> <span class="string">git</span> <span class="string">add</span> <span class="string">.</span></div><div class="line"><span class="bullet">  -</span> <span class="string">git</span> <span class="string">commit</span> <span class="bullet">-m</span> <span class="string">"Update docs"</span></div><div class="line"><span class="bullet">  -</span> <span class="string">git</span> <span class="string">push</span> <span class="bullet">--force</span> <span class="bullet">--quiet</span> <span class="string">"https://$&#123;GITHUB_TOKEN&#125;@$&#123;GH_REF&#125;"</span> <span class="attr">master:master</span></div><div class="line"><span class="bullet">  -</span> <span class="string">ssh-keyscan</span> <span class="string">git.oschina.net</span> <span class="string">&gt;&gt;</span> <span class="string">~/.ssh/known_hosts</span></div><div class="line"><span class="bullet">  -</span> <span class="string">ssh-agent</span> <span class="string">bash</span> <span class="bullet">-c</span> <span class="string">'ssh-add ../$OSC_PRIVATE_KEY_FILE; git push --force $OSC_REF master:master'</span></div><div class="line"><span class="bullet">  -</span> <span class="string">rm</span> <span class="string">../$OSC_PRIVATE_KEY_FILE</span></div><div class="line"><span class="comment"># E: Build LifeCycle</span></div><div class="line"></div><div class="line"><span class="attr">branches:</span></div><div class="line"><span class="attr">  only:</span></div><div class="line"><span class="bullet">    -</span> <span class="string">blog-source</span></div><div class="line"></div><div class="line"><span class="attr">env:</span></div><div class="line"><span class="attr"> global:</span></div><div class="line"><span class="attr">   - GH_REF:</span> <span class="string">github.com/terryding77/terryding77.github.io.git</span></div><div class="line"><span class="attr">   - OSC_REF:</span> <span class="string">git@git.oschina.net:terryding77/terryding77.git</span></div><div class="line"><span class="attr">   - OSC_PRIVATE_KEY_FILE:</span> <span class="string">.encrypted_secret_key</span></div></pre></td></tr></table></figure></p>
<h2 id="部署时间变化"><a href="#部署时间变化" class="headerlink" title="部署时间变化"></a>部署时间变化</h2><p>最后将blog-source分支push到github上去，等待travis-ci自动部署即可，不过从时间上看，时间从1分支变成了5分钟，看来应该是国外服务器push到码云会比较慢的缘故<br><img src="travis-ci-time-compare.png" alt="travis-ci-time-compare"></p>

    

    
</div>


                

                <!-- Post Comments -->
                
                    







                
            </div>

            <!-- Post Prev & Next Nav -->
            <nav class="material-nav mdl-color-text--grey-50 mdl-cell mdl-cell--12-col">
    <!-- Prev Nav -->
    
        <a href="/2017/04/18/OracleSqlWithAs/" id="post_nav-newer" class="prev-content">
            <button class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon mdl-color--white mdl-color-text--grey-900" role="presentation">
                <i class="material-icons">arrow_back</i>
            </button>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            新篇
        </a>
    

    <!-- Section Spacer -->
    <div class="section-spacer"></div>

    <!-- Next Nav -->
    
</nav>

        </div>
    </div>



                    
                        <!-- Overlay For Active Sidebar -->
<div class="sidebar-overlay"></div>

<!-- Material sidebar -->
<aside id="sidebar" class="sidebar sidebar-colored sidebar-fixed-left" role="navigation">
    <div id="sidebar-main">
        <!-- Sidebar Header -->
        <div class="sidebar-header header-cover" style="background-image: url(/img/sidebar_header.png);">
    <!-- Top bar -->
    <div class="top-bar"></div>

    <!-- Sidebar toggle button -->
    <button type="button" class="sidebar-toggle mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon" style="display: initial;" data-upgraded=",MaterialButton,MaterialRipple">
        <i class="material-icons">clear_all</i>
        <span class="mdl-button__ripple-container">
            <span class="mdl-ripple">
            </span>
        </span>
    </button>

    <!-- Sidebar Avatar -->
    <div class="sidebar-image">
        <img src="/img/avatar.png" alt="Terry Ding's avatar">
    </div>

    <!-- Sidebar Email -->
    <a data-toggle="dropdown" class="sidebar-brand" href="#settings-dropdown">
        terryding77@gmail.com
        <b class="caret"></b>
    </a>
</div>


        <!-- Sidebar Navigation  -->
        <ul class="nav sidebar-nav">
    <!-- User dropdown  -->
    <li class="dropdown">
        <ul id="settings-dropdown" class="dropdown-menu">
            
                <li>
                    <a href="#" target="_blank" title="Email Me">
                        
                            <i class="material-icons sidebar-material-icons sidebar-indent-left1pc-element">email</i>
                        
                        Email Me
                    </a>
                </li>
            
        </ul>
    </li>

    <!-- Homepage -->
    
        <li id="sidebar-first-li">
            <a href="/" target="_self">
                
                    <i class="material-icons sidebar-material-icons">home</i>
                
                主页
            </a>
        </li>
        
    

    <!-- Archives  -->
    
        <li class="dropdown">
            <a href="#" class="ripple-effect dropdown-toggle" data-toggle="dropdown">
                
                    <i class="material-icons sidebar-material-icons">inbox</i>
                
                    归档
                <b class="caret"></b>
            </a>
            <ul class="dropdown-menu">
            <li>
                <a class="sidebar_archives-link" href="/archives/2017/04/">四月 2017<span class="sidebar_archives-count">5</span></a>
            </ul>
        </li>
        
    

    <!-- Categories  -->
    
        <li class="dropdown">
            <a href="#" class="ripple-effect dropdown-toggle" data-toggle="dropdown">
                
                    <i class="material-icons sidebar-material-icons">chrome_reader_mode</i>
                
                分类
                <b class="caret"></b>
            </a>
            <ul class="dropdown-menu">
                <li>
                <a class="sidebar_archives-link" href="/categories/cpp/">cpp<span class="sidebar_archives-count">1</span></a></li><li><a class="sidebar_archives-link" href="/categories/cpp/大数运算/">大数运算<span class="sidebar_archives-count">1</span></a></li><li><a class="sidebar_archives-link" href="/categories/cpp/大数运算/快速幂/">快速幂<span class="sidebar_archives-count">1</span></a></li><li><a class="sidebar_archives-link" href="/categories/python/">python<span class="sidebar_archives-count">1</span></a></li><li><a class="sidebar_archives-link" href="/categories/python/正则/">正则<span class="sidebar_archives-count">1</span></a>
            </ul>
        </li>
        
    

    <!-- Pages  -->
    

    <!-- Article Number  -->
    
</ul>


        <!-- Sidebar Footer -->
        <!--
I'm glad you use this theme, the development is no so easy, I hope you can keep the copyright, I will thank you so much.
If you still want to delete the copyrights, could you still retain the first one? Which namely "Theme Material"
It will not impact the appearance and can give developers a lot of support :)

很高兴您使用并喜欢该主题，开发不易 十分谢谢与希望您可以保留一下版权声明。
如果您仍然想删除的话 能否只保留第一项呢？即 "Theme Material"
它不会影响美观并可以给开发者很大的支持和动力。 :)
-->

<!-- Sidebar Divider -->

    <div class="sidebar-divider"></div>


<!-- Theme Material -->

    <a href="https://github.com/viosey/hexo-theme-material"  class="sidebar-footer-text-a" target="_blank">
        <div class="sidebar-text mdl-button mdl-js-button mdl-js-ripple-effect sidebar-footer-text-div" data-upgraded=",MaterialButton,MaterialRipple">
            主题 - Material
            <span class="sidebar-badge badge-circle">i</span>
        </div>
    </a>


<!-- Help & Support -->
<!--

-->

<!-- Feedback -->
<!--

-->

<!-- About Theme -->
<!--

    <a href="https://blog.viosey.com/index.php/Material.html" target="_blank" class="sidebar-footer-text-a">
        <div class="sidebar-text mdl-button mdl-js-button mdl-js-ripple-effect sidebar-footer-text-div" data-upgraded=",MaterialButton,MaterialRipple">
             sidebar.about_theme
            <span class="mdl-button__ripple-container"><span class="mdl-ripple"></span></span></div>
    </a>

-->

    </div>

    <!-- Sidebar Image -->
    

</aside>

                    

                    
                        <!-- Footer Top Button -->
                        <div class="toTop-wrap">
    <a href="#top" class="toTop">
        <i class="material-icons footer_top-i">expand_less</i>
    </a>
</div>

                    

                    <!--Footer-->
<footer class="mdl-mini-footer" id="bottom">
    
        <!-- Paradox Footer Left Section -->
        <div class="mdl-mini-footer--left-section sns-list">
    <!-- Twitter -->
    
        <a href="https://twitter.com/twitter" target="_blank">
            <button class="mdl-mini-footer--social-btn social-btn" style="background-image: url(/img/footer/footer_ico-twitter.svg);">
                <span class="visuallyhidden">Twitter</span>
            </button><!--
     --></a>
    

    <!-- Facebook -->
    
        <a href="https://www.facebook.com/facebook" target="_blank">
            <button class="mdl-mini-footer--social-btn social-btn" style="background-image: url(/img/footer/footer_ico-facebook.svg);">
                <span class="visuallyhidden">Facebook</span>
            </button><!--
     --></a>
    

    <!-- Google + -->
    
        <a href="https://www.google.com/" target="_blank">
            <button class="mdl-mini-footer--social-btn social-btn" style="background-image: url(/img/footer/footer_ico-gplus.svg);">
                <span class="visuallyhidden">Google Plus</span>
            </button><!--
     --></a>
    

    <!-- Weibo -->
    

    <!-- Instagram -->
    

    <!-- Tumblr -->
    

    <!-- Github -->
    
        <a href="https://github.com/terryding77" target="_blank">
            <button class="mdl-mini-footer--social-btn social-btn" style="background-image: url(/img/footer/footer_ico-github.svg);">
                <span class="visuallyhidden">Github</span>
            </button><!--
     --></a>
    

    <!-- LinkedIn -->
    

    <!-- Zhihu -->
    

    <!-- Bilibili -->
    

    <!-- Telegram -->
    
</div>


        <!--Copyright-->
        <div id="copyright">
            Copyright&nbsp;©&nbsp;
            <script type="text/javascript">
                var fd = new Date();
                document.write(fd.getFullYear());
            </script>
            &nbsp;Terry Ding's Blog
        </div>

        <!-- Paradox Footer Right Section -->

        <!--
        I am glad you use this theme, the development is no so easy, I hope you can keep the copyright.
        It will not impact the appearance and can give developers a lot of support :)

        很高兴您使用该主题，开发不易，希望您可以保留一下版权声明。
        它不会影响美观并可以给开发者很大的支持。 :)
        -->

        <div class="mdl-mini-footer--right-section">
            <div>
                <div class="footer-develop-div">Powered by <a href="https://hexo.io" target="_blank" class="footer-develop-a">Hexo</a></div>
                <div class="footer-develop-div">Theme - <a href="https://github.com/viosey/hexo-theme-material" target="_blank" class="footer-develop-a">Material</a></div>
            </div>
        </div>
    
</footer>


                    <!-- Import File -->

    <script src="/js/lazyload.min.js"></script>
    <script src="/js/js.min.js"></script>



    <script src="/js/nprogress.js"></script>


<script type="text/javascript">
    NProgress.configure({
        showSpinner: true
    });
    NProgress.start();
    $('#nprogress .bar').css({
        'background': '#29d'
    });
    $('#nprogress .peg').css({
        'box-shadow': '0 0 10px #29d, 0 0 15px #29d'
    });
    $('#nprogress .spinner-icon').css({
        'border-top-color': '#29d',
        'border-left-color': '#29d'
    });
    setTimeout(function() {
        NProgress.done();
        $('.fade').removeClass('out');
    }, 800);
</script>





    <!-- Leancloud -->
    <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
    <script>
        AV.initialize('gd4dvpF8B1gW7DnvMsKeYeMj-gzGzoHsz', 'CbToyIaOMs3ciCkNEbyCWpAq');
    </script>
    <script>
    function showTime(Counter) {
        var query = new AV.Query(Counter);
        $('.leancloud-views_num').each(function() {
            var url = $(this).attr('id').trim();
            query.equalTo('url', url);
            query.find({
                success: function(results) {
                    if (results.length === 0) {
                        var content = '0 ' + $(document.getElementById(url)).text();
                        $(document.getElementById(url)).text(content);
                        return;
                    }
                    for (var i = 0; i < results.length; i++) {
                        var object = results[i];
                        var content = object.get('time') + ' ' + $(document.getElementById(url)).text();
                        $(document.getElementById(url)).text(content);
                    }
                },
                error: function(object, error) {
                    console.log('Error: ' + error.code + ' ' + error.message);
                }
            });
        });
    }

    function addCount(Counter) {
      var Counter = AV.Object.extend('Counter');
      url = $('.leancloud-views_num').attr('id').trim();
      title = $('.leancloud-views_num').attr('data-flag-title').trim();
      var query = new AV.Query(Counter);
      query.equalTo('url', url);
      query.find({
          success: function(results) {
            if (results.length > 0) {
                var counter = results[0];
                counter.fetchWhenSave(true);
                counter.increment('time');
                counter.save(null, {
                    success: function(counter) {
                        var content =  counter.get('time') + ' ' + $(document.getElementById(url)).text();
                        $(document.getElementById(url)).text(content);
                    },
                    error: function(counter, error) {
                        console.log('Failed to save Visitor num, with error message: ' + error.message);
                    }
                });
            } else {
              var newcounter = new Counter();
              newcounter.set('title', title);
              newcounter.set('url', url);
              newcounter.set('time', 1);
              newcounter.save(null, {
                  success: function(newcounter) {
                      console.log('newcounter.get(\'time\')='+newcounter.get('time'));
                      var content = newcounter.get('time') + ' ' + $(document.getElementById(url)).text();
                      $(document.getElementById(url)).text(content);
                  },
                  error: function(newcounter, error) {
                      console.log('Failed to create');
                  }
              });
            }
        },
        error: function(error) {
            console.log('Error:' + error.code + ' ' + error.message);
        }
      });
    }
    $(function() {
        var Counter = AV.Object.extend('Counter');
        if ($('.leancloud-views_num').length === 1) {
            addCount(Counter);
        } else if ($('.post-title-link').length > 1) {
            showTime(Counter);
        }
    });
</script>













<!-- Window Load-->
<script>
    $(window).load(function() {
        // Post_Toc parent position fixed
        $('.post-toc-wrap').parent('.mdl-menu__container').css('position', 'fixed');
    });
</script>

<!-- MathJax Load-->

<script>
    <!-- Offer LazyLoad -->
    queue.offer(function(){
        $('.lazy').lazyload({
            effect : 'show'
        });
    });

    <!-- Start Queue -->
    $(document).ready(function(){
        setInterval(function(){
            queue.execNext();
        },200);
    });
</script>

                </main>
            </div>
        </body>
    
</html>
